#include <iostream>
#include <map>
#include <string>
#include <vector>
#include <algorithm>
#include <fstream>
#include <thread>
using namespace std;

class Print
{
public:
	Print() {}
	void operator()(const string &strValue)
	{
		cout << strValue << endl;
	}
};

void CppSTLTest()
{
	std::map<int, std::string> tmap;
	tmap[0] = "a";
	tmap[0] = "a";
	tmap[0] = "b";
	tmap[0] = "c";
	tmap[1] = "d";
	tmap[1] = "d";
	tmap[2] = "e";
	tmap[2] = "e";
	tmap[3] = "f";
	tmap[3] = "f";
	tmap[4] = "f";
	tmap[4] = "g";

	for (auto it : tmap)
	{
		std::cout << it.first << "--" << it.second << std::endl
	}

	std::vector<std::string> vctAllGx;
	vctAllGx.push_back("a");
	vctAllGx.push_back("m");
	vctAllGx.push_back("b");
	vctAllGx.push_back("c");
	vctAllGx.push_back("d");
	vctAllGx.push_back("n");
	vctAllGx.push_back("e");
	vctAllGx.push_back("k");
	vctAllGx.push_back("f");
	vctAllGx.push_back("w");
	vctAllGx.push_back("x");
	vctAllGx.push_back("g");

	for (auto it : vctAllGx)
	{
		std::cout << it << ", ";
	}
	cout << endl;
	Print pt;
	std::for_each(vctAllGx.begin(), vctAllGx.end(), Print());

	std::map<bool, std::vector<std::string>> mapSelGx;
	mapSelGx[true].push_back("a");
	mapSelGx[false].push_back("b");
	mapSelGx[true].push_back("c");
	mapSelGx[true].push_back("d");
	mapSelGx[false].push_back("e");
	mapSelGx[true].push_back("m");
	mapSelGx[false].push_back("k");
	mapSelGx[true].push_back("w");

	for (auto it : mapSelGx)
	{
		for (auto v : it.second)
		{
			std::cout << it.first << "-" << v << ", ";
		}
	}

	auto itRemove = std::remove_if(vctAllGx.begin(), vctAllGx.end(), [&](const string &vctGxId) -> bool {
		auto itmap = find_if(mapSelGx.begin(), mapSelGx.end(), [&](const bool &bIsUsing, const string &mapGxId) -> bool {
			return mapGxId == vctGxId && bIsUsing != true;
		});
		return itmap != mapSelGx.end();
	});

	vctAllGx.erase(itRemove, vctAllGx.end());

	cout << endl;
	for (auto it : vctAllGx)
	{
		std::cout << it << ", ";
	}

	cout << endl;
}

void CppExercise()
{
	extern "C" _declspec(dllexport) void CppExercise();

	int f;
	cout << f << endl; //δ֪����

	int bar{};
	cout << bar << endl; //0

	fstream file;
	file.open("Json_ptree_write.json", ios::in);
	if (file)
	{
		cout << "�ļ�����" << endl;
	}
	else
	{
		cout << "�ļ�������" << endl;
	}
}

struct base
{
	virtual ~base() {}
	virtual void foo(int a = 1)
	{
		cout << "base��" << a << endl;
	}
};

void bar(void *arg)
{
	base *b = reinterpret_cast<base *>(arg);
}

struct derived : public base
{
	virtual void foo(int a = 2) override
	{
		cout << "derived��" << a << endl;
	}
};

int a = 1;
void foo()
{
	while (true)
	{
		printf_s("%d\n", a);
		a++;
	}
}

int main()
{

	cout << endl
		 << endl
		 << endl;
	system("pause");
	return 0;
}

//************************************
// Author:  xuxueqian
// Method:  fun
// Access:  public
// Parameter:  int a
// Parameter:  int b
// Return:  void
//************************************
void fun(int a, int b)
{
	vector<int> v1 = {34, 5, 6, 23, 67, 8, 3, 99};
	vector<int> v2 = {1, 34, 3, 5, 23, 6, 78, 6};
	vector<int> v3;
	sort(v1.begin(), v1.end());
	sort(v2.begin(), v2.end());
	set_intersection(v1.begin(), v1.end(), v2.begin(), v2.end(), back_inserter(v3));
	for (auto v : v3)
		cout << v << " ";
}

void fun(int a, int b);
//main����
int main()
{
	float s1 = 0.00001;
	float s2 = 0.0001;
	if (s1 < s2)
		cout << "s1<s2" << endl;
	if (s1 > s2)
		cout << "s1>s2" << endl;

	return 0;
}